package com.example.demo.util;

import org.json.JSONArray;
import org.json.JSONObject;

/**
 * @Classname JsonMachine
 * @Description TODO
 * @Date 2019/9/20 11:15
 * @Created by yby
 */
public class JsonMachine {

    public static void main(String[] args) {

            JSONObject object = new JSONObject();

            JSONArray jsonArray = new JSONArray();
            JSONObject jsonObject = new JSONObject();
			jsonObject.put("buyType", 1);
			jsonObject.put("buyNumber", 1);
			jsonObject.put("size", 1);
			jsonArray.put(jsonObject);

            jsonObject = new JSONObject();
			jsonObject.put("buyType", 2);
			jsonObject.put("buyNumber", 2);
			jsonObject.put("size", 2);
			jsonArray.put(jsonObject);


            JSONObject json = new JSONObject();
			json.put("cpOdd", "mqttTest2");
			json.put("orderId", "1");
			json.put("result", jsonArray);
			json.put("time",String.valueOf(System.currentTimeMillis()));
    //json.put("secretkey",selectConnectConfig.getSecretkey());
    String md5Str = "cpOdd=mqttTest2&orderId=1&result="+jsonArray.toString()+"&time="+String.valueOf(System.currentTimeMillis())+"&secretkey=324ef32342f2r3222";
			json.put("sign","afaf2f13212afafaa");
        object.put("data",json);
        object.put("type","chupiao");
        object.put("topic","mqttTest");
        System.out.println("json="+object.toString());

    }
}
